//
// Created by user on 2022/1/20.
//

#ifndef F103RC_WS2812B_COLOR_UTILS_H
#define F103RC_WS2812B_COLOR_UTILS_H

#include <stdint.h>

struct CHSV;

struct CRGB {
    uint8_t r, g, b;

    CRGB() : r(0), g(0), b(0) {};

    CRGB(uint8_t _r, uint8_t _g, uint8_t _b) : r(_r), g(_g), b(_b) {};

    CRGB(const CHSV &hsv) { *this = hsv; }

    CRGB &operator=(const CHSV &hsv);

    CRGB &operator+=(const CRGB &o);

    CRGB &operator*=(const float v) {
        r *= v;
        g *= v;
        b *= v;
        return *this;
    }

    CRGB operator*(const float v) const {
        return CRGB(r * v, g * v, b * v);
    }
};

struct CHSV {
    uint8_t h, s, v;

    CHSV() : h(0), s(0), v(0) {}

    CHSV(uint8_t _h, uint8_t _s, uint8_t _v) : h(_h), s(_s), v(_v) {}

    CHSV(CRGB rgb);
};

#endif //F103RC_WS2812B_COLOR_UTILS_H
